<?php

namespace App\Events\OpenShop;

use Illuminate\Broadcasting\Channel;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Broadcasting\PresenceChannel;
use Illuminate\Broadcasting\PrivateChannel;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels;

class OrderEditedEvent
{
    use Dispatchable, InteractsWithSockets, SerializesModels;

    public array  $originalOrderData      = [];
    public array  $newOrderData           = [];
    public int    $rmsUserId              = 0;
    public string $datetime               = '';
    public array  $originalBaseInfo       = [];
    public array  $newBaseInfo            = [];
    public array  $originalUserIdentity   = [];
    public array  $newUserIdentity        = [];
    public array  $originalWorkExperience = [];
    public array  $newWorkExperience      = [];
    public array  $beforeContract         = [];
    public array  $afterContract          = [];

    /**
     * Create a new event instance.
     *
     * @return void
     */
    public function __construct(array $originalOrderData, array $newOrderData, int $rmsUserId,
                                array $originalBaseInfo = [],
                                array $newBaseInfo = [], array $originalUserIdentity = [], array $newUserIdentity = [],
                                array $originalWorkExperience = [], array $newWorkExperience = [],
                                array $beforeContract = [], array $afterContract = []
    )
    {
        $this->originalOrderData      = $originalOrderData;
        $this->newOrderData           = $newOrderData;
        $this->rmsUserId              = $rmsUserId;
        $this->datetime               = now()->toDateTimeString();
        $this->originalBaseInfo       = $originalBaseInfo;
        $this->newBaseInfo            = $newBaseInfo;
        $this->originalUserIdentity   = $originalUserIdentity;
        $this->newUserIdentity        = $newUserIdentity;
        $this->originalWorkExperience = $originalWorkExperience;
        $this->newWorkExperience      = $newWorkExperience;
        $this->beforeContract         = $beforeContract;
        $this->afterContract          = $afterContract;
    }

    /**
     * Get the channels the event should broadcast on.
     *
     * @return \Illuminate\Broadcasting\Channel|array
     */
    public function broadcastOn()
    {
        return new PrivateChannel('channel-name');
    }
}
